package com.xaicode.template.rabbitmq;

import com.xaicode.template.rabbitmq.service.RabbitService;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.concurrent.TimeUnit;

/**
 * @author Locker
 * @date 2021/8/20 0020 17:09
 */
@Component
@Order(1)
public class InitialRunner implements CommandLineRunner {

    @Resource
    private RabbitService rabbitService;

    /**
     * Callback used to run the bean.
     *
     * @param args incoming main method arguments
     * @throws Exception on error
     */
    @Override
    public void run(String... args) throws Exception {
        System.out.println("- initial ");
        TimeUnit.SECONDS.sleep(3);
        rabbitService.broadcast("broadcast message test");
        rabbitService.direct("direct message test");
    }
}
